package com.zqq.goods.service.impl

import com.zqq.baselibrary.ext.convert
import com.zqq.goods.service.GoodsService
import com.zqq.goods.service.bean.Goods
import com.zqq.goods.service.repository.GoodsRepository
import rx.Observable
import javax.inject.Inject

/**
 * 商品 业务层 实现类
 * wc
 * @author zqq on 2019/5/28.
 */
class GoodsServiceImpl @Inject constructor() : GoodsService {

    @Inject
    lateinit var repository: GoodsRepository


    /**
     * 获取商品列表
     */
    override fun getGoodsList(categoryId: Int, pageNo: Int): Observable<MutableList<Goods>?> {
        return repository.getGoodsList(categoryId, pageNo)
                .convert()
    }

    /**
     * 根据关键字查询商品
     */
    override fun getGoodsListByKeyword(keyword: String, pageNo: Int): Observable<MutableList<Goods>?> {
        return repository.getGoodsListByKeyword(keyword, pageNo)
                .convert()
    }

    /**
     * 获取商品详情
     */
    override fun getGoodsDetail(goodsId: Int): Observable<Goods> {
        return repository.getGoodsDetail(goodsId)
                .convert()
    }

}